package com.wolf.lottery.domain.award.service.goods.impl;

import com.wolf.lottery.common.constants.GrantState;
import com.wolf.lottery.domain.award.model.req.GoodsReq;
import com.wolf.lottery.domain.award.model.res.DistributionRes;
import com.wolf.lottery.domain.award.service.goods.DistributionBase;
import com.wolf.lottery.domain.award.service.goods.IDistributionGoods;
import org.springframework.stereotype.Component;

/**
 * @description: 兑换码类商品
 * @author: wolf
 * @date: 2023/6/14
 */
@Component
public class RedeemCodeGoods extends DistributionBase implements IDistributionGoods {

    @Override
    public DistributionRes doDistribution(GoodsReq req) {

        // 模拟调用实物发奖
        logger.info("模拟调用实物发奖 uId：{} awardContent：{}", req.getuId(), req.getAwardContent());

        // 更新用户颁奖结果
        super.updateUserAwardState(req.getuId(), req.getOrderId(), req.getAwardId(), GrantState.COMPLETE.getCode());

        return new DistributionRes(req.getuId(), GrantState.COMPLETE.getCode(), GrantState.COMPLETE.getInfo());
    }
}
